package org.pz.mq;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MqConfig {

    public static final String user_task_queue = "user_task_queue";

    public static final String user_task_exchange = "user_task_exchange";

    public static final String user_task_bind_key = "user_task_bind_key";

    //队列
    @Bean
    public Queue userTaskQueue(){
        return new Queue(user_task_queue);
    }

    @Bean
    public DirectExchange userTaskExchage(){
        return new DirectExchange(user_task_exchange, false, false);
    }

    @Bean
    public Binding binding(Queue userTaskQueue, DirectExchange userTaskExchage){
        return BindingBuilder.bind(userTaskQueue).to(userTaskExchage).with(user_task_bind_key);
    }
}
